package edu.whu.rose.clock.kps.datastruct;

import edu.whu.rose.clock.kps.algorithm.banks1.AnswerTree;
import edu.whu.rose.clock.ssql.util.MyMath;

public class SimpleAnswer {

	private int root;
	private int[] matched_vertexes;
	private int[][] paths;
	private int[] all_vertexes;
	private double score;

	public SimpleAnswer(int root, int[] matched_vertexes, int[][] paths,
			int[] allVertexes) {
		this.root = root;
		this.matched_vertexes = matched_vertexes;
		this.paths = paths;
		this.all_vertexes = allVertexes;
		score = score();
	}

	public int compare(SimpleAnswer at) {
		return MyMath.compareIntArrays2(all_vertexes, at.getAllVertexes());
	}
	
	private double score() {
		double score = 0.0d;
		for (int i = 0; i < matched_vertexes.length; i++) {
			if (paths[i] != null)
				score += paths[i].length;
		}
		return score;
	}

	public double getScore() {
		return score;
	}

	public int getRoot() {
		return root;
	}

	public int[] getAllVertexes() {
		return all_vertexes;
	}

	public int getLeafNumber() {
		return paths.length;
	}

	public int[] getPath(int index) {
		return paths[index];
	}

	public int[] getLeaves() {
		return matched_vertexes;
	}
}
